let _calBack = null;
let __env = GameGlobal.wx || GameGlobal.tt || GameGlobal.swan;
function ongetData(_data) {
  let slefOpenid = _data.userInfo;
    wx.getFriendCloudStorage({
    keyList: ['rankData'],
    success: (res) => {
      let data = res.data
      for (let k in data) {
        data[k].KVDataList[0].value = JSON.parse(res.data[k].KVDataList[0].value)
      }
      data.sort((a, b) => b.KVDataList[0].value.score - a.KVDataList[0].value.score);
      // console.log("获取数据", data)
      _calBack&&_calBack(data,slefOpenid)
    },
    fail: (res) => {
      // console.log("存储失败", res)
      _calBack&&_calBack([])
    }
  })
}
function dataReturnBack(_calBack1){
  // console.warn("成男")
  _calBack = _calBack1
}
__env.onMessage(data => {
  // console.log("data", data)
  if (data.event == "getRank") {
    ongetData(data)
  }
});

module.exports = dataReturnBack;